exports.bargain_list = function (req, res) {

    var restfulParams = req.routeInfo.restfulParams;

    //最终结果
    var resultData = {};

    var skip  =  restfulParams.skip == undefined  ? 0 : restfulParams.skip;
    var limit =  restfulParams.limit == undefined ? config.publicConfig.LIMIT : restfulParams.limit;


    //任务流创建
    async.waterfall([

        //查询我参与的投票列表
        function (cb) {

            R.SEND_HTTP(
                req,
                {
                    url: CORE_APIConfig.coreAPI.searchBargainJoinAndActivityInfo + "/bj_uid/" + restfulParams.u_id + "/sort_order/bj_create_time-desc/skip/" + skip + "/limit/" + limit,
                    method: 'POST',
                    data: {
                        fields: ["bj_create_time",
                                  "oa_start_time",
                                  "oa_end_time",
                                  "bc_least_price",
                                  "bc_most_price",
                                  "bj_get_cut_count",
                                  "oa_title",
                                  "oa_id",
                                  "bc_course_count",
                                  "oa_title_image",
                                  "bj_get_cut_price",
                                  "bj_is_order",
                                  "oa_oid",
                                  "bj_is_complete",
                                  "bj_oid",
                                   "o_name"
                        ].join(",")
                    }
                },
                function (err, data) {
                    ////console.log(data.data);
                    //判断是否有错误信息
                    if (err) {
                        return cb(err, data);
                    }

                    resultData.bargainData = data.data;

                    cb();
                }
            );
        },


        function(cb){

            var tasks = [];

            //循环节点列表
            resultData.bargainData.forEach(function (item, i) {
                //创建每一个插入任务
                tasks.push(function (cb) {

                    item.now_price = parseFloat(parseFloat(item.bc_most_price) - parseFloat(item.bj_get_cut_price)).toFixed(2);

                    cb();

                });

            });

            async.waterfall(tasks, cb);


        },





        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

}